package com.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.entity.Catalogue;


public class CatalogCtrl {

			public ArrayList<Catalogue> getCatalog(){
			ArrayList<Catalogue> acata = null;
			Connection conn = ConnDB.getConn();
			Statement stmt = null;
			ResultSet rs = null;
			String sql = "select catalog_id,catalog_name from catalogue";
			try {
				stmt = conn.createStatement();
				rs = stmt.executeQuery(sql);
				while (rs.next()) {
					if (acata == null) {
						acata = new ArrayList<Catalogue>();
					}
					Catalogue catalogue = new Catalogue();
					catalogue.setCatalog_id(rs.getInt("catalog_id"));
					catalogue.setCatalog_name(rs.getString("catalog_name"));
							
					acata.add(catalogue);
				}
				return acata;
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} finally {
				ConnDB.close(rs, stmt, conn);
			}
			return acata;
		}
				
	}


